package com.yc;

import com.google.gson.internal.bind.util.ISO8601Utils;

import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;
import java.util.Scanner;

public class Test4_Client {
    //Test3的客户端程序
    public static void main(String[] args) throws IOException {
        Socket s = new Socket("localhost", 65534);
        System.out.println("联接成功");
        //使用输入流来接时间
        try (InputStreamReader iis = new InputStreamReader(s.getInputStream());) {
            char[] chs = new char[1024];
            int length = 1;
            while ((length = iis.read(chs, 0, chs.length)) != -1) {
                String str = new String(chs, 0, length);
                System.out.println(str);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("客户端断开与服务器的联接");
        s.close();
    }


}
